﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using System.ComponentModel;

namespace TA.Turbo.Controls
{
	internal class ControlReferenceClient
	{
		public ControlReferenceClient(BaseControlReference source)
			: this()
		{
			this.ControlId = source.Control.ClientID;
			this.SendAs = source.SendAs;
			this.Value = source.Value;
			if (source.PropertiesMode == InclusionMode.OnlyIncluded)
				this.PropertiesList = source.PropertiesList.ToArray();
			else
			{
				if (source.Control is BaseControl)
				{
					List<string> propertiesList = new List<string>();
					foreach (string prName in ((BaseControl)source.Control)._properties.Keys)
					{
						if (!source.PropertiesList.Contains(prName))
							propertiesList.Add(prName);
					}
					this.PropertiesList = propertiesList.ToArray();
				}
			}
		}
		public ControlReferenceClient(BaseValueControl control)
			: this()
		{
			this.ControlId = control.ClientID;
		}
		protected ControlReferenceClient()
		{
			this.Value = true;
			this.PropertiesList = new string[0];
		}

		public string ControlId { get; set; }
		public string SendAs { get; set; }
		public bool Value { get; set; }
		public string[] PropertiesList { get; set; }
	}
}